home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / dbms_mag / 9103 / lastlog / verid.c < prev    next >
C/C++ Source or Header  |  1991-02-17  |  2KB  |  75 lines

  1. /*****************************************************************
  2. *  VerID.C
  3. *  written by Kathy Cea, Platinum Software Int'l
  4. *
  5. *  Verifies an application id/user id combination for
  6. *  the user calling the program.  Designed to be used from a
  7. *  batch file.
  8. *
  9. *  Calling Syntax:
  10. *       VerID <appl-id> <user-id>
  11. *         where <appl-id> is the name given to the application (note
  12. *                         that this must match the name used in the
  13. *                         AddID program)
  14. *               <user-id> is the user's id for the application
  15. *                         (again, this must match the id assigned to
  16. *                         the user through the AddID program).
  17. *
  18. *  Returns:
  19. *     0 - Match (successful)
  20. *     1 - No match
  21. *     2 - Can't read property Value
  22. *     3 - Too few parameters supplied
  23. *
  24. *   Compiled in Turbo C 2.0 with NetWare C function calls
  25. *****************************************************************/
  26.  
  27. #include <stdio.h>
  28. #include <nit.h>
  29. #include <niterror.h>
  30.  
  31. WORD ConnectNumber;
  32. long objectID;
  33. BYTE loginTime[7];
  34. char objectName[48];
  35. WORD objectType;
  36. char propertyName[16];
  37. char applName[13];
  38. BYTE propertyFlags;
  39. BYTE submitValue[128],
  40.      actualValue[128];
  41. BYTE moreSegments;
  42. int retcode;
  43. int segNum = 1;
  44.  
  45. main(int argc, char *argv[])
  46. {
  47.    if(argc < 3) {
  48.         printf("Too few parameters supplied\n");
  49.         exit(3);
  50.     }
  51.  
  52.     strcpy(applName,strupr(argv[1]));
  53.     strcpy(submitValue,strupr(argv[2]));
  54.     strcpy(propertyName,applName);
  55.     strcat(propertyName,"ID");
  56.  
  57. /* Get user's object name */
  58.     ConnectNumber =  GetConnectionNumber();
  59.     GetConnectionInformation(ConnectNumber, objectName,
  60.             &objectType, &objectID,loginTime);
  61.  
  62. /* Get the application ID property value */
  63.     retcode = ReadPropertyValue(objectName,objectType,propertyName,segNum,
  64.                 actualValue,&moreSegments,&propertyFlags);
  65.     if (retcode != SUCCESSFUL) /* Can't read value */
  66.         exit(2);
  67.  
  68. /* Compare submitted ID with ID found in bindery */
  69.     if (!stricmp(submitValue,actualValue)) /* Match */
  70.         exit(0);
  71.     else /* No match */
  72.         exit(1);
  73. }
  74.  
  75.